//
//  ZYStatusModel.swift
//  WBBeta1
//
//  Created by wustzhy on 16/8/13.
//  Copyright © 2016年 Yestin. All rights reserved.
//

import UIKit

class ZYStatusModel: NSObject {

//原创
    //    created_at	string	微博创建时间
    var created_at:String?
    //    id	int64	微博ID
    var id:Int64 = 0
    //    text	string	微博信息内容
    var text:String?
    //    source	string	微博来源
    var source:String?
//原创 图片
    var pic_urls:[ZYPictureInfo]?

//底部视图
    // int	转发数
    var reposts_count: Int = 0
    // int	评论数
    var comments_count: Int = 0
    //int	表态数
    var attitudes_count: Int = 0

//转发微博
    var retweeted_status:ZYStatusModel?
    
//user嵌套模型
    var user:ZYUserModel?
    
    //重写 setValueForKey
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let v = value as? [String:AnyObject] else{
                return
            }
            user = ZYUserModel(dict: v)
        }else if key == "retweeted_status" {
            guard let v = value as? [String:AnyObject] else{
                return
            }
            retweeted_status = ZYStatusModel(dic: v)
        }else if key == "pic_urls" {
            guard let vv = value as? [[String:AnyObject]] else{
                return
            }
//            var tempArr:[String:AnyObject] = [String:AnyObject]()
            var tempArr: [ZYPictureInfo] = [ZYPictureInfo]()
            for v in vv{
                let pic = ZYPictureInfo(dict: v)
                tempArr.append(pic)
            }
            pic_urls = tempArr
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
    
    
    
    

    init(dic:[String:AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
}
